package com.poklaan.frein.http;

import com.blankj.utilcode.util.ToastUtils;
import com.google.gson.Gson;
import com.kongzue.baseokhttp.listener.ResponseListener;
import com.poklaan.baseapp.http.BaseResponse;

/**
 * Created by myzcx on 2017/12/27.
 */

public abstract class ResponsechildListener extends ResponseListener {

    @Override
    public void response(Object response, Exception error) {


        if (response == null) {
            ToastUtils.showShort("Data anomaly!");
        } else {
            BaseResponse b = new Gson().fromJson(response.toString(), BaseResponse.class);
            if (b.getCode() != 0) {
                ToastUtils.showShort(b.getMsg());
            } else {
                if (b.getResult()==null)b.setResult("");
                responseData(new Gson().toJson(b.getResult()));
            }
        }
    }

    public abstract void responseData(String response);


}

